﻿@{
    ViewBag.Title = "AlbumDir";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
@using System.Collections;
<link href="/Areas/Admin/content/js/swfupload/swfupload.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="/Areas/Admin/content/js/jquery.imgpreview.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var obj = $("#imgPreview a[rel]");
        if (obj.length > 0) {
            $('#imgPreview a[rel]').imgPreview({
                srcAttr: 'rel',
                imgCSS: { width: 200 }
            });
        }
    });
</script>
<div class="table-list">
    <table width="100%" cellspacing="0" id="imgPreview">
        <tr>
            <td>当前目录：@Html.Raw(Request.QueryString["dir"])/
            </td>
        </tr>
        @if (Request.QueryString["dir"].ToLower() != "upload")
        {
            <tr>
                <td>
                    <img src="/Areas/Admin/content/img/folder-closed.gif" />
                    <a href="javascript:history.back();">返回上一级目录</a>
                </td>
            </tr>
        }
        @foreach (string item in (ViewData["folderlist"] as ArrayList))
        {
            <tr>
                <td align="left">
                    <img src="/Areas/Admin/content/img/folder-closed.gif" />
                    <a href="?dir=@Html.Raw(Request.QueryString["dir"] + "/" + item)"><b>@item</b></a>
                </td>
            </tr>
        }
        @foreach (string item in (ViewData["filelist"] as ArrayList))
        {
            <tr>
                <td align="left" onclick="javascript:album_cancel(this)">
                    <img src="/Areas/Admin/content/img/ext/@Html.Raw(item.Substring(item.LastIndexOf(".") + 1) + ".gif")" />
                    <a href="javascript:;" rel="/@Html.Raw(Request.QueryString["dir"] + "/" + item)">
                        @item</a>
                </td>
            </tr>
        }
    </table>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        set_status_empty();
    });
    function set_status_empty() {
        parent.window.$('#att-status').html('');
    }
    function album_cancel(obj) {
        var src = $(obj).children("a").attr("rel");
        if ($(obj).hasClass('on')) {
            $(obj).removeClass("on");
            var imgstr = parent.window.$("#att-status").html();
            var length = $("a[class='on']").children("a").length;
            var strs = '';
            for (var i = 0; i < length; i++) { strs += '|' + $("a[class='on']").children("a").eq(i).attr('rel'); }
            parent.window.$('#att-status').html(strs);
        } else {
            var num = parent.window.$('#att-status').html().split('|').length;
            var file_upload_limit = '8';
            $(obj).addClass("on");
            parent.window.$('#att-status').append('|' + src);
        }
    }
</script>
